using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Linq.Expressions;
using System.Web;

namespace AlphaWebsite.Models
{ 
    public class WeddingEventListsRepository : IWeddingEventListsRepository
    {
        AlphaWebsiteContext context = new AlphaWebsiteContext();

        public IQueryable<WeddingEventLists> All
        {
            get { return context.WeddingEventLists; }
        }

        public IQueryable<WeddingEventLists> AllIncluding(params Expression<Func<WeddingEventLists, object>>[] includeProperties)
        {
            IQueryable<WeddingEventLists> query = context.WeddingEventLists;
            foreach (var includeProperty in includeProperties) {
                query = query.Include(includeProperty);
            }
            return query;
        }

        public WeddingEventLists Find(System.Guid id)
        {
            return context.WeddingEventLists.Find(id);
        }

        public void InsertOrUpdate(WeddingEventLists weddingeventlists)
        {
            if (weddingeventlists.EventListID == default(System.Guid)) {
                // New entity
                weddingeventlists.EventListID = Guid.NewGuid();
                context.WeddingEventLists.Add(weddingeventlists);
            } else {
                // Existing entity
                context.Entry(weddingeventlists).State = EntityState.Modified;
            }
        }

        public void Delete(System.Guid id)
        {
            var weddingeventlists = context.WeddingEventLists.Find(id);
            context.WeddingEventLists.Remove(weddingeventlists);
        }

        public void Save()
        {
            context.SaveChanges();
        }

        public void Dispose() 
        {
            context.Dispose();
        }
    }

    public interface IWeddingEventListsRepository : IDisposable
    {
        IQueryable<WeddingEventLists> All { get; }
        IQueryable<WeddingEventLists> AllIncluding(params Expression<Func<WeddingEventLists, object>>[] includeProperties);
        WeddingEventLists Find(System.Guid id);
        void InsertOrUpdate(WeddingEventLists weddingeventlists);
        void Delete(System.Guid id);
        void Save();
    }
}